<%@ page import="car.aistar.dto.TqxCarSelect" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2020/9/22
  Time: 8:48 上午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div class="container" style="text-align: center">
    <ul class="pagination">
        <li><a href="javascript:next_page(1)">首页</a></li>

        <c:if test="${pageNow<=1}">
            <li class="disabled"><a href="#">&laquo;</a></li>
        </c:if>

        <c:if test="${pageNow>1}">
            <li><a href="javascript:next_page(${pageNow-1})">&laquo;</a></li>
        </c:if>

        <c:if test="${pageNow+2<=pageNums}">
            <c:set var="endPage" value="${pageNow+2}"></c:set>
            <c:set var="startPage" value="${pageNow}"></c:set>
        </c:if>

        <c:if test="${pageNow+2>pageNums}">
            <c:set var="endPage" value="${pageNums}"></c:set>
            <c:set var="startPage" value="${pageNums-2}"></c:set>
        </c:if>

        <c:if test="${startPage<=0}">
            <c:set var="startPage" value="1"></c:set>
        </c:if>


        <c:forEach begin="${startPage}" end="${endPage}" var="v">
            <li <c:if test="${pageNow == v}">class="active"</c:if></li> <a href="javascript:next_page(${v})">${v}</a></li>
        </c:forEach>

        <c:if test="${pageNow<pageNums}">
            <li><a href="javascript:next_page(${pageNow+1})">&raquo;</a></li>
        </c:if>

        <c:if test="${pageNow>=pageNums}">
            <li class="disabled"><a href="#">&raquo;</a></li>
        </c:if>

        <li><a href="javascript:next_page(${pageNums})">尾页</a></li>
        <li><a> 当前页${pageNow}/${pageNums}总页</a></li>
        <li><a style="padding: 0;border: none;margin-left: 2px"><input placeholder="跳转页" class="form-control" value="" id="toPage">

        </a></li>
        <li><a style="padding: 0;border: none"><button type="button" class="btn btn-info" onclick="to_page()">Go</button></a></li>

    </ul>
    <input type="text" value="${pageNums}" id="pageNums" class="hidden">
</div>

<input type="text"  id="path "class=" hidden" value="<%=request.getContextPath()%>">
<script>

    var path = $("#path").val()
    var pageNums = $("#pageNums").val()
    function to_page() {
        // alert(pageNums)
        let pageto = $("#toPage").val();
        if(pageto>pageNums || pageto<0){
            alert("请输入指定范围的页码(1~"+pageNums+")")
        }else {
            next_page(pageto);
        }

    }
    function next_page(page){
        let size = $("#pageSizeSelect").val();
        // if(size==-1||size==null)
        //     size=12
        $("#content").load(path+"/carDetail/index/carInfo/"+page+"/12")
    }

    // function page_size(obj){
    //     $("#content").load(path+"/carDetail/index/carInfo/1/"+obj.value)
    // }
</script>